<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>监理服务系统</title>
    <!--公用样式-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/comment.css"/>
    <!--页面样式-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/style.css"/>
    <!--Layui-->
    <link rel="stylesheet" href="${re.contextPath}/plugin/layui/css/layui.css" media="all"/>
    <!--页面样式-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/extended.css"/>
    <!--JQ-->
    <script type="text/javascript" charset="utf-8"
            src="${re.contextPath}/plugin/common/js/jquery-1.8.3.min.js"></script>
    <!--Layui-->
    <script type="text/javascript" src="${re.contextPath}/plugin/layui/layui.js" charset="utf-8"></script>
    <!--公用样式JS-->
    <script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/common/js/comment.js"></script>
    <script type="text/javascript" src="${re.contextPath}/pageoffice.js" id="po_js_main"></script>
</head>


<body>
<!--容器-->

<div class="container clearfix">
    <div style="width: 100%;" class="Right fr">
        <div class="return mt20">
            <img class="close" src="${re.contextPath}/plugin/common/images/32@2x.png" alt=""/>
            <span class="close">返回上一页</span>
        </div>
        <div class="processBtn clearfix">
            <#if "${lc_type}" =='1' >
                <button type="button" class="greenbg white bor0 fl" onclick="checkClick(2)">通过</button>
                <button type="button" class="redbg white bor0 fl ml10" onclick="checkClick(3)">驳回</button>
            </#if>
            <#if "${iscx}" =='1' >
                <button type="button" class="redbg white bor0 fl ml10" onclick="checkClick(4)">撤回</button>
            </#if>
            <#if "${lc_type}" =='3' >
                <button type="button" class="bluebg white bor0 fl ml10" onclick="doCheck('2','')">归档</button>
            </#if>
        </div>
        <div class="processCont clearfix ">
            <div class="fl whitebg">
                <div class="ft22 bold">
                    ${affairCase.caseName}
                </div>
                <#if "${affairCase.memo}" !=null && "${affairCase.memo}"!="" >
                    <div class="ft22"
                         style="color: red;margin-top: 30px;padding-bottom: 30px; border-bottom: 1px solid #EEEEEE;">
                        驳回原因：${affairCase.memo}
                    </div>
                </#if>
                <ul>
                    <li>发起人：${fquser.realName}</li>
                    <li>发起时间：${affairCase.acceptTime}</li>
                    <li>流程类型：${lctype.badtName}</li>
                    <li>项目名称：${project.projectName}</li>
                    <li>项目类型：${ywtype.badtName}</li>
                    <input id="taskId" type="hidden" name="taskId" value="${taskId}">
                    <input id="taskName" type="hidden" name="taskName" value="${taskName}">
                    <input id="caseId" type="hidden" name="caseId" value="${affairCase.caseId}">
                    <input id="lcType" type="hidden" name="lcType" value="${affairCase.lcType}">
                    <input id="processInstanceId" type="hidden" name="processInstanceId"
                           value="${affairCase.processInstanceId}">
                    <input id="businessId" type="hidden" name="businessId" value="${affairCase.businessId}">
                </ul>
                <div class="processFile">
                    <ul>
                        <li>
                            <img src="${re.contextPath}/plugin/common/images/61@2x.png" alt=""/>
                            <span class="ml10 cursor" id="${file.id}" type="${file.type}"
                                  onclick="view(this)">${file.fileName}</span>
                            <#if "${gz}"=="1"  >
                                <input type="button" value="签章" class="seal" onclick="sealClick(this)"
                                       style="background-color: #6ce26c;color: #0C0C0C;font-weight: inherit;font-style: inherit;">
                            </#if>
                            <#if "${qz}"=="1"  >
                                <input type="button" value="签字" class="seal" onclick="sealClick(this)"
                                       style="background-color: #6ce26c;color: #0C0C0C;font-weight: inherit;font-style: inherit;">
                            </#if>
                            <#if "${isyzqz}"=="1">
                                <input type="button" value="上传附件" class="upseal tabsealup0"
                                       style="background-color: #6ce26c;color: #0C0C0C;font-weight: inherit;font-style: inherit;">
                            </#if>
                        </li>

                    </ul>
                </div>
            </div>
            <div class="fr whitebg">
                <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief"
                     style=" padding-left: 0px; padding-right: 0px;">
                    <ul class="layui-tab-title">
                        <li class="layui-this focus">流程历史列表</li>
                        <li onclick="showLcView()">流程图</li>
                    </ul>
                    <div class="layui-tab-content">
                        <div class="layui-tab-item layui-show">
                            <div class="processChild">
                                <!--流程历史列表-->
                                <div>
                                    <ul class="gary mt20" id="lcrecord">
                                    </ul>
                                </div>
                            </div>
                        </div>
                        <div class="layui-tab-item"></div>

                    </div>
                </div>


            </div>
        </div>
    </div>
</div>
<!--公用样式JS-->
<script type="text/javascript" src="${re.contextPath}/plugin/tools/tool.js"></script>
<script type="text/javascript" src="${re.contextPath}/plugin/tools/cardUtils.js"></script>

<script type="text/html" id="toolBar">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看详情</a>
</script>

<script>
    var layer, form, laydate, upload, uploadListIns, element, tableIns, table;
    $(function () {
        layui.use(['form', 'layer', 'upload', 'element'], function () {
            laydate = layui.laydate;
            form = layui.form;
            element = layui.element;
            upload = layui.upload;
            /*业主单位绑定盖章事件*/
            bindSeal();
        });
        //初始化流程记录信息
        queryLcRecord();

    });

    /*绑定盖章*/
    function bindSeal() {
        var datajson = {
            "id": '${project.id}',
            "parentId": '${affairCase.businessId}',
            "uploadType": "004",
            "type": "113"
        }
        upload.render({
            elem: ".tabsealup0",
            url: '/supervisor/projectManager/addFileFj',//改成您自己的上传接口
            multiple: false,
            accept: 'file',
            auto: true,
            data: datajson,
            done: function (res, index, upload) {
                var flag = res.flag;
                if (flag) {
                    layer.msg("图片上传成功,正在操作签章", {icon: 1})
                    setTimeout(function () {
                        POBrowser.openWindowModeless('/sys/office/openword?ft=11&fid=' + datajson.parentId, 'width=1200px;height=800px;', '{}')
                    }, 3000);

                } else {
                    layer.msg("文件上传失败", {icon: 2})
                }

            },
            error: function (index, upload) {
                console.log(index, upload);
                layer.msg("文件上传失败", {icon: 2})
            }
        });

    }

    //查看
    function view(object) {
        var fileid = $(object).attr("id");
        POBrowser.openWindowModeless('/sys/office/openword?ft=3&fid=' + fileid, 'width=1200px;height=800px;', '{}')
    }

    function sealClick(object) {
        var fileid = $(object).prev().attr("id");
        POBrowser.openWindowModeless('/sys/office/openword?ft=9&fid=' + fileid, 'width=1200px;height=800px;', '{}')
    }

    function queryLcRecord() {
        var userName = '${vo.userName}';
        var hjName = '${vo.hjName}';
        var operDate = '${vo.operDate}';
        var jsonsp = {
            caseId: '${affairCase.caseId}'
        };
        //初始化流程记录信息
        layerAjaxGet('/supervisor/lcManager/queryLcRecord', jsonsp, '', function (d) {
            if (d.flag == true) {
                var recorddata = d.data;
                $("#lcrecord").html("");
                for (var i = 0; i < recorddata.length; i++) {
                    $("#lcrecord").append("<li>" + recorddata[i].userName + "  " + recorddata[i].hjName + "  " + recorddata[i].remark + "   " + recorddata[i].operDate + "；</li>");
                }

            } else {
                layer.msg(d.msg, {icon: 2});
            }
            console.log(d);
        });

    }

    function exportFile(object) {
        var fileid = $(object).attr("id");
        window.open("/supervisor/projectManager/exportFile?id=" + fileid);
    }


    function showLcView() {
        var w = "";
        var h = "";
        if (w == null || w == '') {
            w = ($(window).width());
        }
        ;
        if (h == null || h == '') {
            h = ($(window).height() - 50);
        }
        var lcid = '${affairCase.processInstanceId}';
        parent.layer.open({
            id: 'delcare-image',
            type: 2,
            area: [w + 'px', h + 'px'],
            fix: false,
            maxmin: true,
            shadeClose: false,
            shade: 0.4,
            title: '流程图',
            content: '${re.contextPath}/leave/shinePics/' + lcid
        });
    }

    function checkClick(checkStatus) {
        //按钮不可用
        var checkStatus = checkStatus;
        var type = "auto";
        if (checkStatus == "3") {
            //填写驳回原因
            layer.open({
                type: 1
                ,
                offset: type, //
                area: ['600px', '300px'],
                id: 'layerDemo' + type //防止重复弹出
                ,
                content: '<div style="align-content: center;"><div style="margin-top: 10px;margin-left: 60px;font-weight:bold;" class="b">驳回原因</div><textarea id="remark"  name="remark" style="width: 450px;height: 100px;margin-left: 60px;margin-bottom: 10px;" placeholder="请填写驳回原因"></textarea></div>'
                ,
                btn: '关闭全部'
                ,
                btnAlign: 'c' //按钮居中
                ,
                shade: 0 //不显示遮罩
                ,
                btn: ['确定', '关闭'] //只是为了演示
                ,
                yes: function () {
                    var remark = $("#remark").val();
                    if (!remark) {
                        layer.msg("请输入驳回原因", {icon: 2});
                        return
                    } else {
                        doCheck(checkStatus,"gb",remark);
                    }

                }
                ,
                btn2: function () {
                    layer.closeAll();
                }
            });

        } else if(checkStatus=="2") {
            var processInstanceId = $("#processInstanceId").val();
            // caseId
            var caseId = $("#caseId").val();
            // 任务id
            var taskId = $("#taskId").val();

            var taskName = $("#taskName").val();
            var  isqz="${isqz}";
            // 业务表id
            var businessId = $("#businessId").val();
            var url = "/supervisor/lcManager/checkRemark?processInstanceId=" + processInstanceId + "&caseId=" + caseId + "&taskId=" + taskId + "&taskName=" + encodeURI(taskName) + "&businessId=" + businessId + "&isqz="+isqz+"";
                layer.open({
                    type: 2,
                    area: ['60%', '300px'],
                    fix: false,
                    maxmin: true,
                    shadeClose: false,
                    shade: 0.4,
                    title: "审核意见",
                    content: url,
                    btnAlign: 'c', //按钮居中
                    btn: ['提交', '关闭'], //只是为了演示
                    yes: function (index,layero) {
                        var body = layer.getChildFrame('body',index);
                        var remark=$(body).find("#remark").val();
                       if(isqz=="1"){
                           layer.confirm('请确定是否已经签字？', {
                               btn: ['确定', '取消'],
                           }, function (index) {
                               doCheck(checkStatus,"gb",remark);
                           }, function (index) {
                               // 恢复按钮可用
                               $('[type=button]').removeClass("layui-btn-disabled").attr("disabled", false);
                           });
                       }else{
                           doCheck(checkStatus,"gb",remark);
                       }

                    } ,
                    btn2: function () {
                        layer.closeAll();
                    }
                })
        }else  if(checkStatus=="4"){
            /*撤回*/
            doCheck(checkStatus,"","");
        }
    }

    $('.close').click(function () {
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    });

    function doCheck(checkStatus,isgb,remark) {
        $('[type=button]').addClass("layui-btn-disabled").attr("disabled", true);
        //流程实例id
        var processInstanceId = $("#processInstanceId").val();
        // caseId
        var caseId = $("#caseId").val();
        // 任务id
        var taskId = $("#taskId").val();

        var taskName = $("#taskName").val();
        // 业务表id
        var businessId = $("#businessId").val();

        var jsonc = {
            processInstanceId: processInstanceId,
            caseId: caseId,
            taskId: taskId,
            businessId: businessId,
            remark: remark,
            checkStatus: checkStatus,
            taskName: taskName
        }
        var url = "/supervisor/lcManager/updateCheckJlNB";
        if (checkStatus == "4") {
            layer.confirm('确定撤回流程吗？', {
                btn: ['确定', '取消'],

            }, function (index) {
                layerAjax(url, jsonc, '', function (d) {
                    if (d.flag == true) {
                        queryLcRecord();
                        layer.msg(d.msg);
                    } else {
                        // 恢复按钮可用
                        $('[type=button]').removeClass("layui-btn-disabled").attr("disabled", false);
                        layer.msg(d.msg, {icon: 2});
                    }
                });
            }, function (index) {
                // 恢复按钮可用
                $('[type=button]').removeClass("layui-btn-disabled").attr("disabled", false);

            });
        } else  {
                layerAjax(url, jsonc, '', function (d) {
                    if (d.flag == true) {
                        queryLcRecord();
                        layer.msg(d.msg);
                        if(isgb=="gb"){
                            setTimeout(function () {
                                layer.closeAll();
                            }, 500);
                        }
                    } else {
                        // 恢复按钮可用
                        $('[type=button]').removeClass("layui-btn-disabled").attr("disabled", false);
                        layer.msg(d.msg, {icon: 2});
                    }
                });
        }

    }


</script>
</body>

</html>